package com.clkj.goldpartner.dao;

import com.clkj.goldpartner.pojo.Warehouse;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author 杨行
 * @date 2021/3/3 15:21
 */
@Repository
public interface WarehouseMapper extends Mapper<Warehouse> {

    /**
     * 获取仓库列表
     *
     * @param shop_id
     * @param warehouse_name
     * @param warehouse_type
     * @return
     */
    @Select("<script>" +
            "select * from t_cl_warehouse where shop_id = #{shop_id} and warehouse_status = '0' and warehouse_name like '%${warehouse_name}%'" +
            "<if test=' 0!=warehouse_type '> and warehouse_type = #{warehouse_type} </if> " +
            "</script>")
    List<Warehouse> getWarehouse(Integer shop_id, String warehouse_name, String warehouse_type);

    /**
     * 删除仓库
     *
     * @param ids
     */
    @Update("update t_cl_warehouse set warehouse_status = '1' where warehouse_id in (${ids})")
    void deleteWarehouse(@Param("ids") String ids);
}
